import request from "@/utils/http";

export const addCartAPI = (skuId, count) => {
  return request({
    url: "/member/cart",
    data: { skuId, count },
    method: "post",
  });
};

export const getCartsAPI = () => {
  return request({ url: "/member/cart" });
};

export const updateCartAPI = (selected, id) => {
  return request({
    url: "/member/cart/selected",
    method: "put",
    data: {
      selected,
      ids: id ? [id] : undefined,
    },
  });
};

export const updateCartCoutnAPI = (id, count, selected) => {
  return request({
    method: "put",
    url: `/member/cart/${id}`,
    data: {
      count,
      selected,
    },
  });
};

// 1.
export const delCartByIdAPI = (id) => {
  return request({
    url: "/member/cart",
    method: "delete",
    data: { ids: [id] },
  });
};

// 3. 封装API
export const getOrderDetailAPI = (id) => {
  return request({ url: "/member/order/" + id });
};
